﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Phone
{
    public partial class Ringing : Form
    {
        //默认构造函数
        public Ringing()
        {
            InitializeComponent();
        }

        //窗体加载时显示呼叫者号码
        private void Ringing_Load(object sender, EventArgs e)
        {
            switch (Vars.busy_sip_or_pstn)
            {
                case "sip":
                    label1.Text = Vars.sip?.GetRemoteUser();
                    break;
                case "pstn1":
                    label1.Text = Vars.pstn1?.GetRemoteUser();
                    break;
                case "pstn2":
                    label1.Text = Vars.pstn2?.GetRemoteUser();
                    break;
            }
        }

        //拒绝接听
        private void button1_Click(object sender, EventArgs e)
        {
            switch (Vars.busy_sip_or_pstn)
            {
                case "sip":
                    Vars.sip?.UserOptionSelect("Decline");
                    break;
                case "pstn1":
                    Vars.pstn1?.UserOptionSelect("Decline");
                    break;
                case "pstn2":
                    Vars.pstn2?.UserOptionSelect("Decline");
                    break;
            }
        }

        //接听
        private void button2_Click(object sender, EventArgs e)
        {
            switch (Vars.busy_sip_or_pstn)
            {
                case "sip":
                    Vars.sip?.UserOptionSelect("Accept");
                    break;
                case "pstn1":
                    Vars.pstn1?.UserOptionSelect("Accept");
                    break;
                case "pstn2":
                    Vars.pstn2?.UserOptionSelect("Accept");
                    break;
            }
        }
    }
}
